package com.aaa.depression.service;


import com.aaa.depression.dao.DepressionReportStatisticsDao;
import com.aaa.pojo.DepressionResult;
import com.aaa.pojo.ResultBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

@Service
public class DepressionReportStatisticsServiceImpl implements DepressionReportStatisticsService {
    @Autowired
    private DepressionReportStatisticsDao depressionReportStatisticsDao;

    @Override
    public Map<String,Integer> findAllsds() {
        int normal = 0;
        int mild = 0;
        int moderate = 0;
        int severe = 0;
        List<DepressionResult> viewSdss = depressionReportStatisticsDao.findAllsds();
        Iterator var6 = viewSdss.iterator();

        while(var6.hasNext()) {
            DepressionResult viewSds = (DepressionResult)var6.next();
            double forward = viewSds.getForward();
            double inversion = viewSds.getInversion();
            double sum = (forward + inversion) * 1.25D;
            if (sum < 53.0D) {
                ++normal;
            } else if (sum < 63.0D) {
                ++mild;
            } else if (sum < 73.0D) {
                ++moderate;
            } else {
                ++severe;
            }
        }

        Map<String, Integer> map = new HashMap();
        map.put("normal", normal);
        map.put("mild", mild);
        map.put("moderate", moderate);
        map.put("severe", severe);
        return map;
    }
}
